How can I create a boolean in the `if` statement within the for loop to check for existence of term prepended to filename %%f?

Posted by user784637 on Stack Overflow See other posts from Stack Overflow or by user784637
Published on 2012-12-16T10:54:19Z Indexed on 2012/12/16 11:03 UTC
Read the original article Hit count: 185

Filed under:

I have lyrics for about 60% of my song collection. The filename of the lyrics is the same as the file name of song with zzz_ prepended to the filename and .lrc as the extension.

C:\Songs\album\song.mp3
C:\Songs\album\zzz_song.lrc

I currently print the file names like so

for /r "C:\Songs" %%f in (*.mp3 *.flac) do (    
    echo %%f
)

How can I create a boolean in the if statement within the for loop as a check on the existence of lyrics files?

I was thinking something like

if exist zzz_%f echo zzz_%f.lrc

but zzz_%f prepends zzz_ to the full file path (ex. zzz_C:\Songs\album\song.mp3) and .lrc is appended to the existing extension

© Stack Overflow or respective owner

Related posts about batch